home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / earcd / dev / mui / muiplusp.lha / Rexx / Doc2Def.rexx < prev   
OS/2 REXX Batch file  |  1997-03-16  |  3KB  |  125 lines

  1. /* Converts MUI autodocs to MUIDefs files */
  2.  
  3. parse arg destination
  4.  
  5. whitespace = '09'x || ' '
  6.  
  7. /* Get the files to convert */
  8.  
  9. call rtfilerequest(,,"Select files to convert",,"rtfi_flags=freqf_multiselect",files)
  10.  
  11. do i = 1 to files.count
  12.     call CreateDefsFile(files.i)
  13. end
  14.  
  15. exit
  16.  
  17. /* Given the name of an autodoc file this will create it's muidefs file */
  18.  
  19. CreateDefsFile:
  20.     parse arg fileName
  21.     parse var fileName 'MUI_' className '.doc'
  22.  
  23.     if className = '' then do
  24.         parse var fileName 'MCC_' className '.doc'
  25.  
  26.         if className = '' then do
  27.             say fileName "is not a MUI autodoc"
  28.             return
  29.         end
  30.     end
  31.  
  32.     if ~open(file,fileName,'read') then do
  33.         say "Could not open" fileName
  34.         return
  35.     end
  36.  
  37.     destName = destination || className'.muidefs'
  38.  
  39.     if ~open(destFile,destName,'write') then do
  40.         say "Could not open destination file" destName "for writing"
  41.         call close(file)
  42.         return
  43.     end
  44.  
  45.     say "Converting" fileName "to" destName"..."
  46.  
  47.     do while ~eof(file)
  48.         line = strip(readln(file),'b',whitespace)
  49.  
  50.         if line = 'NAME' then do
  51.             line = strip(readln(file),'b',whitespace)
  52.  
  53.             tag = word(line,1)
  54.  
  55.             if word(line,words(line)) = '(OBSOLETE)' then do
  56.                 obselete = 'O'
  57.                 line = substr(line,1,wordindex(line,words(line)) - 1)
  58.             end
  59.  
  60.             else obselete = 'N'
  61.  
  62.             if left(tag,4) = 'MUIA' then do
  63.                 /* Get name of attribute */
  64.  
  65.                 parse var tag 'MUIA_' class '_' attribute
  66.  
  67.                 /* Nofity and Area classes do not have a class name before
  68.                    attribute names in tags */
  69.  
  70.                 if attribute = '' then attribute = class
  71.  
  72.                 if attribute = 'Object' then do
  73.                     call writech(stdout,className "class has an attribute called Object, enter new name: ")
  74.                     parse pull attribute
  75.                 end
  76.  
  77.                 /* Get type */
  78.  
  79.                 type = right(line,length(line) - lastpos(',',line) - 1)
  80.  
  81.                 /* There is a bug in the MUI documentation that has Broker
  82.                    instead of CxObj * */
  83.  
  84.                 if strip(type) = 'Broker *' then type = 'CxObj *'
  85.  
  86.                 /* There is also a bug in NList documentation that has Obj *
  87.                    as type for Object * */
  88.  
  89.                 if strip(type) = 'Obj *' then type = 'Object *'
  90.  
  91.                 /* Check whether it is setable, getable or initializer */
  92.  
  93.                 parse var line with _ '[' usage ']' _
  94.  
  95.                 call writeln(destFile,"attribute" tag attribute obselete usage type)
  96.             end
  97.  
  98.             else do
  99.                 /* Get name of method */
  100.  
  101.                 parse var tag 'MUIM_' class '_' method
  102.  
  103.                 /* Nofity and Area classes do not have a class name before
  104.                    attribute names in tags */
  105.  
  106.                 if method = '' then method = class
  107.  
  108.                 /* Get parameters to method */
  109.  
  110.                 do forever
  111.                     if strip(readln(file),'b',whitespace) = 'SYNOPSIS' then break
  112.                 end
  113.  
  114.                 parse value readln(file) with 'DoMethod(' _ ',' _ ',' params ');'
  115.  
  116.                 call writeln(destFile,"method" tag method obselete params)
  117.             end
  118.         end
  119.     end
  120.  
  121.     call close(file)
  122.     call close(destFile)
  123.  
  124. return
  125.